var http_request;
var params;

function toserver(f) {
        

        var url = "http://silo.cs.indiana.edu:13795/servlet/CreateNymServlet?nym=";
        var snym = f.username.value;
        alert(snym);
        url += snym;
        var semail = f.email.value;
        alert(semail);
        url += "&email=";
        url += semail;
        url += "&pwd=";
       
        var password = f.password.value;
        alert(password);
        url += password;

    //    params = "nym="+snym+"&email="+semail+"&pwd="+password+"";
    
  //      params = "nym="+snym+"";
       //   var url = "loadXMLDoc("http://silo.cs.indiana.edu:13795/servlet/CreateNymServlet?");";
 
          loadXMLDoc(url);
          setTimeout(url, 0);

}

function loadXMLDoc(url) {

        //alert(url);

        if (window.XMLHttpRequest){

        http_request = new XMLHttpRequest();
     //   http_request.onreadystatechange =  function() {  alertContents(http_request); };
        http_request.open('GET', url, true);
        http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        http_request.send("");
        http_request.onreadystatechange = alertContents;
                      //initialize the request
     }

      else if(window.ActiveXObject){
          //Create our RequestObject
          http_request = new ActiveXObject("Microsoft.XMLHTTP");
          if(http_request){
                http_request.onreadystatechange = function() { alertContents(http_request); };
                http_request.open('GET', url, true);
                http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
                http_request.send("");                      //initialize the request
                }
          }

     if (!http_request) {
            alert('Giving up :( Cannot create an XMLHTTP instance');
            return false;
        }


}

function alertContents(){

        try {

            if (http_request.readyState == 4) {
                //      alert("fine");
               if (http_request.status == 200) {
                    alert(http_request.responseText);
                                                           
 } else {
                    alert('There was a problem with the request.');
                }
            }
        }
        catch( e ) {
             alert('Caught Exception: ' + e);
        }
  }

                                
